using imitateMacQQ.WebApi.Domain.Friend.module.Entity;
using imitateMacQQ.WebApi.Domain.Friend.module.Entity.dao;
using imitateMacQQ.WebApi.Domain.Friend.module.Entity.dto;
using imitateMacQQ.WebApi.Domain.Friend.module.Interface;
using imitateMacQQ.WebApi.Domain.Request.utils;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace imitateMacQQ.WebApi.Api.Friend;

[ApiController]
[Route("api/[controller]/[action]")]
public class FriendController : ControllerBase
{
    private readonly IFriend _friend;

    public FriendController(IFriend friend)
    {
        _friend = friend;
    }


    [HttpGet]
    public async Task<Request<string[]>> GetStrList(string account)
    {
        return await _friend.GetFriendListStr(account);
    }


    [Authorize]
    [HttpGet]
    public Request<Domain.Friend.module.Entity.Friend[]> GetFriendList(
        string accountSelf)
    {
        return _friend.GetFriendList(accountSelf);
    }

    [Authorize]
    [HttpPost]
    public Request<bool> AskFriendRelation(AskFriend friend)
    {
        return _friend.AskFriendRelation(friend);
    }

    [Authorize]
    [HttpPost]
    public Request<bool> AskResult(AskFriendResult dto)
    {
        return _friend.AskResult(dto);
    }

    [Authorize]
    [HttpPost]
    public async Task<Request<bool>> GetRelation(Relation dto)
    {
        return await _friend.AskRelation(dto);
    }

    [HttpGet]
    public async Task<Request<RequestList[]>> GetRequestList(string account)
    {
        return await _friend.GetRequestList(account);
    }
}